from sklearn.datasets import make_blobs
from sklearn.cluster import AgglomerativeClustering
import matplotlib.pyplot as plt

NUM_CLASSES = 4 
NUM_FEATURES = 2
colors = ('orange', 'yellow', 'cyan', 'black')

fig,axs = plt.subplots(1,6,figsize=(20,3))

for deviation in [1,2,3]:
    X,y = make_blobs(n_samples=80, n_features=NUM_FEATURES,
                     centers=NUM_CLASSES, cluster_std=deviation,
                     random_state=14)
    
    agl_clustering = AgglomerativeClustering(n_clusters = NUM_CLASSES)
    clusters = agl_clustering.fit_predict(X)

    axs[(deviation-1)*2].scatter(X[:,0], X[:,1], c = y)
    axs[(deviation-1)*2].set_title('samples, noise: ' + str(deviation))
    axs[(deviation-1)*2].axis("off")

    for i in range(len(y)):
        color = colors[clusters[i]]
        axs[(deviation-1)*2+1].scatter(X[i,0],X[i,1], c = color)
    axs[(deviation-1)*2+1].set_title('agglomerative')
    axs[(deviation-1)*2+1].axis("off")